package cos.android.voleysplash;


import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cos.android.voleysplash.level.Utils;
import cos.android.voleysplash.viewythread.PlaygroundView;

public class VoleySplash extends Activity {
	
	
	private PlaygroundView playgroundView;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        playgroundView = (PlaygroundView) findViewById(R.id.playground);
		playgroundView.setFpsTextView((TextView) findViewById(R.id.fps));
		playgroundView.setLayout((RelativeLayout) findViewById(R.id.layout));
		Bundle intent = getIntent().getExtras();
		if (intent != null) {
			int level = intent.getInt("level");
			int world = intent.getInt("world");
			playgroundView.setLevel(level);
			playgroundView.setWorld(world);
		}
        
    }
    
    @Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
 
		menu.add(Menu.NONE, Utils.MENU_INIT, Menu.NONE, R.string.backInitStr);
		menu.add(Menu.NONE, Utils.MENU_RESET, Menu.NONE, R.string.resetStr);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case Utils.MENU_INIT:
			
			finish();
			return true;

		case Utils.MENU_RESET:
			playgroundView.reset();
			return true;
		}
		return false;
	}
    
}